package com.yy.train.ticket.train.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yy.train.ticket.train.entity.TtStationEntity;
import com.yy.train.ticket.train.entity.TtTrainEntity;
import com.yy.train.ticket.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.yy.train.ticket.train.entity.TtGradeEntity;
import com.yy.train.ticket.train.service.TtGradeService;





/**
 * 等级名称
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2023-09-25 10:38:44
 */
@RestController
@RequestMapping("tt/grade")
public class TtGradeController {
    @Autowired
    private TtGradeService ttGradeService;

    /**
     * 列表
     */
    @GetMapping("/list")
    public R list(){

        List<TtGradeEntity> list = ttGradeService.list(Wrappers.<TtGradeEntity>lambdaQuery());
        return R.ok(list);


    }


    /**
     * 信息
     */
    @GetMapping("/info/{gradeId}")
    public R info(@PathVariable("gradeId") Long gradeId){
		TtGradeEntity ttGrade = ttGradeService.getById(gradeId);

        return R.ok(ttGrade);
    }

    /**
     * 保存
     */
    @PostMapping("/save")
    public R save(@RequestBody TtGradeEntity ttGrade){
		ttGradeService.save(ttGrade);

        return R.ok();
    }

    /**
     * 修改
     */
    @PutMapping("/update")
    public R update(@RequestBody TtGradeEntity ttGrade){
		ttGradeService.updateById(ttGrade);

        return R.ok();
    }

    /**
     * 删除
     */
    @DeleteMapping("/delete")
    public R delete(@RequestBody List<Integer> gradeIds){
		ttGradeService.removeByIds(gradeIds);

        return R.ok();
    }

}
